package leetcode.code2064;

import leetcode.IDebug;
import leetcode.helper.H;

public class Solution implements IDebug {

	public int minimizedMaximum(int n, int[] quantities) {
		int l = 1, r = (int) 1e5;
		int ans = 0;
		while (l <= r) {
			int mid = ((r - l) >> 1) + l;
			int cnt = 0;
			for (int i = 0; i < quantities.length; i++) {
				int num = quantities[i];
				cnt += (num + mid - 1) / mid;
			}
			if (cnt <= n) {
				ans = mid;
				r = mid - 1;
			} else {
				l = mid + 1;
			}
		}
		return ans;
	}

	@Override
	public void debug4() {
		H.compare(3, this.minimizedMaximum(6, H.str2array3("[11,6]")));

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
